-
Notifications
You must be signed in to change notification settings - Fork 59
Fix #375: Capture plugin properties at validation time to eliminate timing mismatch #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cowwoc
wants to merge
4
commits into
apache:master
Choose a base branch
from
cowwoc:fix-375-validation-time-capture
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57a76d8 to
d2c8071
Compare
elharo
requested changes
Oct 28, 2025
Contributor
elharo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to run mvn spotless:apply
cowwoc
added a commit
to cowwoc/maven-build-cache-extension
that referenced
this pull request
Oct 29, 2025
- Upgrade spotless-maven-plugin from 2.44.5 to 3.0.0 - Upgrade palantir-java-format from 2.56.0 to 2.81.0 for Java 25 support - Run mvn spotless:apply to format code Addresses review feedback on PR apache#395.
Contributor
Author
|
@elharo Done. Try now. |
elharo
reviewed
Dec 1, 2025
src/main/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategy.java
Outdated
Show resolved
Hide resolved
src/main/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategy.java
Outdated
Show resolved
Hide resolved
src/main/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategy.java
Outdated
Show resolved
Hide resolved
cowwoc
added a commit
to cowwoc/maven-build-cache-extension
that referenced
this pull request
Dec 1, 2025
- Split run-on sentence in AssertionError message - Use HashMap import instead of fully qualified name - Move Mojo variable declaration into try block (nested try-finally) - Return defensive copy from getValidationTimeEvents() for encapsulation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
cowwoc
added a commit
to cowwoc/maven-build-cache-extension
that referenced
this pull request
Dec 1, 2025
- Split run-on sentence in AssertionError message - Use HashMap import instead of fully qualified name - Move Mojo variable declaration into try block (nested try-finally) - Return defensive copy from getValidationTimeEvents() for encapsulation
43445c6 to
fda621a
Compare
cowwoc
added a commit
to cowwoc/maven-build-cache-extension
that referenced
this pull request
Dec 1, 2025
- Split run-on sentence in AssertionError message - Use HashMap import instead of fully qualified name - Move Mojo variable declaration into try block (nested try-finally) - Make getValidationTimeEvents() package-private
fda621a to
6cf3a36
Compare
elharo
requested changes
Dec 1, 2025
…nate timing mismatch Maven 4 automatically injects --module-version into compiler arguments during execution, but cache validation happens before execution. This creates a timing mismatch that causes cache invalidation. This fix captures properties at validation time for ALL builds and stores ONLY validation-time values in the cache, ensuring consistent reading at the same lifecycle point. Changes: - Modified CacheResult to store validation-time mojo events - Added captureValidationTimeProperties() to BuildCacheMojosExecutionStrategy - Modified execute() to capture properties after findCachedBuild() - Modified save() to store ONLY validation-time events (AssertionError if missing) - Added comprehensive integration tests (Maven4Jpms, ExplicitModuleVersion, NonJpms, MultiModule) Benefits: - No configuration required (vs ignorePattern in PR apache#391) - Fixes root cause (timing mismatch) not symptom (value mismatch) - Works for ALL Maven 4 auto-injected properties - Preserves execution-time logging for debugging Alternative to PR apache#391
- Upgrade spotless-maven-plugin from 2.44.5 to 3.0.0 - Upgrade palantir-java-format from 2.56.0 to 2.81.0 for Java 25 support - Run mvn spotless:apply to format code Addresses review feedback on PR apache#395.
- Split run-on sentence in AssertionError message - Use HashMap import instead of fully qualified name - Move Mojo variable declaration into try block (nested try-finally) - Make getValidationTimeEvents() package-private
6cf3a36 to
04b6246
Compare
- Fix invalid XML in pom.xml comment (-- not allowed in XML comments) - Fix cache config XML validation errors by simplifying config - Change tests to use 'package' goal instead of 'compile' since cache extension stores artifacts, not intermediate output directories - Fix AssertionError when running clean-only builds by gracefully skipping cache storage when no cacheable mojos executed
Contributor
Author
|
@elharo I've pushed a commit that should fix the latest build failures. Try now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Maven 4 automatically injects
--module-version ${project.version}into compiler arguments during execution, but the build cache validates properties before execution. This creates a timing mismatch that causes cache invalidation:Root Cause Analysis
The cache extension currently reads plugin properties at different lifecycle points for different builds:
The problem: validation reads BEFORE injection, storage reads AFTER injection.
Solution
Capture properties at validation time for ALL builds (even when no cache exists). Store ONLY validation-time values in the cache. This ensures both validation and storage read at the same lifecycle point.
Implementation
CacheResultto store validation-time mojo eventsBuildCacheMojosExecutionStrategyto capture properties immediately afterfindCachedBuild()save()to store ONLY validation-time events (fails withAssertionErrorif missing)Key Code Changes
Note: Execution-time values are still captured by
MojoParametersListenerfor logging/debugging during the build, but are NOT stored in the cache.New Timeline (Both Builds)
What Gets Stored vs. Logged
This approach ensures cache consistency while preserving debugging information in build logs.
Benefits Over PR #391
ignorePattern)Testing
Created comprehensive integration tests:
--module-versionmoduleVersionconfigurationAll tests verify:
ignorePatternconfiguration requiredBackward Compatibility
ignorePatternstill works but is no longer necessary for Maven 4 injectionAlternative Approaches Considered
Related Issues
Migration
No migration needed. This change is transparent to users. Existing projects will benefit automatically.